package com.yxy.controller.mobile;

import com.yxy.common.PageResult;
import com.yxy.common.Result;
import com.yxy.constant.RequestMapperConstant;
import com.yxy.domain.dto.FeedBackDTO;
import com.yxy.domain.dto.FeedBackPageQueryDTO;
import com.yxy.domain.vo.FeedbackVO;
import com.yxy.service.FeedBackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(RequestMapperConstant.USER_REQUEST_MAPPER + "feedback")
@Slf4j
public class FeedBackController {
    
    private final FeedBackService feedBackService;

    public FeedBackController(FeedBackService feedBackService) {
        this.feedBackService = feedBackService;
    }

    /**
     * 反馈
     * @param feedBackDTO
     * @return
     */
    @PostMapping("/addFeedback")
    public Result<String> feedback(@RequestBody FeedBackDTO feedBackDTO){
        log.info("反馈：{}", feedBackDTO);
        feedBackService.feedBack(feedBackDTO);
        return Result.success("反馈成功");
    }

    /**
     * 查询反馈
     * @param feedBackPageQueryDTO
     * @return
     */
    @GetMapping
    public Result<PageResult> queryFeedBack(FeedBackPageQueryDTO feedBackPageQueryDTO){
        log.info("查询反馈信息：{}", feedBackPageQueryDTO);
        PageResult pageResult = feedBackService.queryFeedBack(feedBackPageQueryDTO);
        return Result.success("", pageResult);
    }

    /**
     * 根据id查询反馈
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<FeedbackVO> getFeedbackById(@PathVariable int id){
        log.info("查询反馈信息：{}", id);
        FeedbackVO vo = feedBackService.getFeedbackById(id);
        return Result.success("", vo);
    }
}
